/**
 *
 * © Bahadir Zeren 2011
 * bzeren@gmail.com
 * No warranties, express or implied, are made for this program.
 *
 */

package org.baatar.opt.genetic.selection;

import java.io.Serializable;
import java.util.ArrayList;
import org.baatar.opt.genetic.chromosome.IChromosome;
import org.baatar.util.RandomUtil;

/**
 * Interface for the selection operators.
 *
 */
public interface ISelection<T, M> extends Serializable, Cloneable {
    /**
     * Selects a chromosome for reproduction (crossover) according to the 
     * algorithm of the implementing class.
     * 
     * @param population current population  of the genetic optimizer.
     * @param range size of the population
     * @param random Randomization class to be used.
     * 
     * @return IChromosome selected chromosome object.
     */
    public IChromosome<T, M> selectChromosomeForReproduction(IChromosome<T, M>[] population, int range, RandomUtil random);

    /**
     * Selects a chromosome for population replacement (survival) according to 
     * the algorithm of the implementing class and returns its index.
     * 
     * @param chromosomeList current total population (population + children) of 
     * the genetic optimizer.
     * @param rangeStart inclusive start index of the range which is used to choose candidate chromosome.
     * @param rangeEnd exclusive end index of the range which is used to choose candidate chromosome.
     * @param random Randomization class to be used.
     * 
     */
    public void replaceChromosomeForSurvival(IChromosome<T, M>[] population, int rangeStart, int rangeEnd, RandomUtil random);

    /**
     * Clones the this object.
     * 
     * @return Object new cloned object.
     * 
     * @throws CloneNotSupportedException is trown if this object doesnt
     * implements Cloneable interface.
     */
    public Object clone() throws CloneNotSupportedException;
}
